<?php

namespace app\store\model\food;


class CardRule extends \app\common\model\food\CardRule
{
    public function add(array $data) {
        //todo校验
//        if (!is_phone($data['phone'])) {
//
//            $this->error = '手机号格式不对';
//
//            return false;
//
//        }
        $data['applet_id'] = self::$applet_id;
        // 创建一个DateTime对象，代表当前时间
        $formattedDate = date('Y-m-d H:i:s');
        $data['create_time_name']=$formattedDate;
        $data['update_time_name']=$formattedDate;
        $this->save($data);
        return true;
    }

    public function list()
    {
       return  $this->with(["shop"])->where('applet_id',self::$applet_id) ->order(['is_delete'=>'asc','create_time'=>'desc'])->paginate(['list_rows'=>10,'query' => request()->param()]);
    }


    public function shop(){
        return $this->belongsTo('app\\common\\model\\food\\Shop',"shop_id");
    }
}